<?php
class Article extends Data_Item
{
    public function articleByKey($key)
    {
        $query = DB::select()
            ->from('mod_article')
            ->where('key', '=', $key)
            ->execute();

        return $query->current();
    }

    public function articleById($id)
    {
        $query = DB::select()
            ->from('mod_article')
            ->where('id', '=', $id)
            ->execute();

        return $query->current();
    }

    public function listByType ($type, $offset = 0, $limit = 10)
    {
        $query = DB::select('id', 'title', 'subtitle', 'thumb', 'summary', 'created')
            ->from('mod_article')
            ->where('type', '=', $type)
            ->offset($offset)
            ->limit($limit)
            ->order_by('sort', 'desc')
            ->execute();

        return $query->as_array();
    }
 
    
}
